﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EricUtility.Networking.Gathering;
using WatchSeriesHelper.Entities;

namespace WatchSeriesHelper.Windows.Forms
{
    public partial class ChooseEpGuideForm : Form
    {
        public string Result = null;
        public ChooseEpGuideForm(string name, List<SearchResultEntry> results)
        {
            string useless = "(a Titles & Air Dates Guide)";
            InitializeComponent();
            lblTitle.Text = name;
            int loc = btnCancel.Top;
            Size = new Size(this.Width, this.Height + 70 * results.Count);
            int i = 0;
            foreach (SearchResultEntry e in results)
            {
                Button b = new Button();
                b.Text = e.Title.Replace(useless,"");
                b.Tag = e.Url.Replace("http://epguides.com/", "").Replace("/", "");
                b.Location = new Point(btnCancel.Left, loc + i);
                b.Size = btnCancel.Size;
                b.Font = btnCancel.Font;
                b.Click += new EventHandler(b_Click);
                Controls.Add(b);
                i+=70;
            }
        }

        void b_Click(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            Result = (string)b.Tag;
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Result = TVShowInfo.NO_EPGUIDE;
            Close();
        }
    }
}
